package com.yunxin.core.application.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import com.yunxin.common.result.PageResult;
import com.yunxin.core.application.admin.team.Team;
import com.yunxin.core.application.assembler.OrderAssembler;
import com.yunxin.core.application.command.order.OrderUserApplyAllocationMerchantPageCommand;
import com.yunxin.core.application.command.order.OrderUserApplyAllocationPageCommand;
import com.yunxin.core.application.command.order.OrderUserApplyPageCommand;
import com.yunxin.core.application.dto.order.*;
import com.yunxin.core.application.service.OrderQueryAdminService;
import com.yunxin.core.application.service.UserQueryAdminService;
import com.yunxin.core.domain.external.channel.ChannelExternalService;
import com.yunxin.core.domain.external.channel.ChannelPromotionInfo;
import com.yunxin.core.domain.external.merchant.MerchantAccount;
import com.yunxin.core.domain.external.merchant.MerchantExternalService;
import com.yunxin.core.domain.external.merchant.MerchantList;
import com.yunxin.core.domain.external.product.ProductExternalService;
import com.yunxin.core.domain.external.product.ProductSimpleInfo;
import com.yunxin.core.infra.persistence.entity.order.OrderUserApplyAllocationDO;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyAllocationMerchantPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyAllocationPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.result.*;
import com.yunxin.core.infra.persistence.mapper.order.ChannelPromotionTwoUvStatisticsMapper;
import com.yunxin.core.infra.persistence.mapper.order.OrderUserApplyAllocationExtendMapper;
import com.yunxin.core.infra.persistence.mapper.order.OrderUserApplyExtendMapper;
import com.yunxin.core.infra.persistence.mapper.product.ProductThrowInConfigExtendMapper;
import com.yunxin.core.utils.infra.common.enums.AccumulationFundLevelEnum;
import com.yunxin.core.utils.infra.common.enums.SocialSecurityLevelEnum;
import com.yunxin.core.utils.infra.support.mybatis.AesEncryptHandler;
import com.yunxin.core.utils.infra.utils.AesUtils;
import com.yunxin.core.utils.infra.utils.DateFormatUtils;
import com.yunxin.core.utils.infra.utils.IdCardNumberUtils;
import com.yunxin.core.utils.infra.utils.PageQueryUtils;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author zero°
 * @since 2023-07-12
 */
@Service
@RequiredArgsConstructor
public class OrderQueryAdminServiceImpl implements OrderQueryAdminService {

    private final OrderUserApplyAllocationExtendMapper orderUserApplyAllocationExtendMapper;

    private final OrderUserApplyExtendMapper orderUserApplyExtendMapper;

    private final MerchantExternalService merchantExternalService;

    private final ChannelExternalService channelExternalService;

    private final ProductExternalService productExternalService;

    private final OrderAssembler orderAssembler;

    private final ChannelPromotionTwoUvStatisticsMapper uvStatisticsMapper;

    @Override
    public List<OrderCountDTO> listOrderCountByProductIds(Set<Long> productIds) {
        Date endTime = new Date();
        Date startTime = DateFormatUtils.X.getDateByStartDate(endTime);
        List<OrderCountResult> results = orderUserApplyAllocationExtendMapper.listOrderCountByProductIds(productIds, startTime, endTime);
        return results.stream().map(x -> {
            OrderCountDTO dto = new OrderCountDTO();
            dto.setProductId(x.getProductId());
            dto.setCount(x.getCount());
            return dto;
        }).toList();
    }

    @Override
    public PageResult<OrderUserApplyAllocationPageDTO> orderUserApplyAllocationPageQuery(OrderUserApplyAllocationPageCommand command) {
        OrderUserApplyAllocationPageCondition condition = orderAssembler.formOrderUserApplyAllocationPageCommand(command);
        long total = orderUserApplyAllocationExtendMapper.countOrderUserApplyAllocationPageQuery(condition);
        if (total == 0) {
            return PageResult.success(Collections.emptyList(), total);
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyAllocationPageResult> results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationPageQuery(condition);
        if (CollUtil.isEmpty(results)) {
            return PageResult.success(Collections.emptyList(), total);
        }
        Set<Long> productIds = results.stream().map(OrderUserApplyAllocationPageResult::getProductId).collect(Collectors.toSet());
        Map<Long, ProductSimpleInfo> productInfoMap = productExternalService.listProductInfoByIds(productIds).stream().collect(Collectors.toMap(ProductSimpleInfo::getId, Function.identity()));
        Set<Long> merchantIds = results.stream().map(OrderUserApplyAllocationPageResult::getMerchantId).collect(Collectors.toSet());
        Map<Long, MerchantList> merchantListResultMap = merchantExternalService.listMerchantByIds(merchantIds).stream().collect(Collectors.toMap(MerchantList::getId, Function.identity()));
        List<OrderUserApplyAllocationPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyAllocationPageDTO dto = orderAssembler.toOrderUserApplyAllocationPageDTO(x);
            ProductSimpleInfo productResult = productInfoMap.get(x.getProductId());
            Optional.ofNullable(productResult).ifPresent(p -> dto.setProductName(p.getProductName()));
            MerchantList result = merchantListResultMap.get(x.getMerchantId());
            Optional.ofNullable(result).ifPresent(m -> dto.setMerchantName(m.getMerchantName()));
            return dto;
        }).toList();
        return PageResult.success(dtoList, total);
    }

    @Override
    public List<OrderUserApplyAllocationPageDTO> orderUserApplyAllocationPageQueryList(OrderUserApplyAllocationPageCommand command) {
        OrderUserApplyAllocationPageCondition condition = orderAssembler.formOrderUserApplyAllocationPageCommand(command);
        long total = orderUserApplyAllocationExtendMapper.countOrderUserApplyAllocationPageQuery(condition);
        if (total == 0) {
            return Collections.emptyList();
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyAllocationPageResult> results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationPageQuery(condition);
        if (CollUtil.isEmpty(results)) {
            return Collections.emptyList();
        }
        Set<Long> productIds = results.stream().map(OrderUserApplyAllocationPageResult::getProductId).collect(Collectors.toSet());
        Map<Long, ProductSimpleInfo> productInfoMap = productExternalService.listProductInfoByIds(productIds).stream().collect(Collectors.toMap(ProductSimpleInfo::getId, Function.identity()));
        Set<Long> merchantIds = results.stream().map(OrderUserApplyAllocationPageResult::getMerchantId).collect(Collectors.toSet());
        Map<Long, MerchantList> merchantListResultMap = merchantExternalService.listMerchantByIds(merchantIds).stream().collect(Collectors.toMap(MerchantList::getId, Function.identity()));
        List<OrderUserApplyAllocationPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyAllocationPageDTO dto = orderAssembler.toOrderUserApplyAllocationPageDTO(x);
            ProductSimpleInfo productResult = productInfoMap.get(x.getProductId());
            Optional.ofNullable(productResult).ifPresent(p -> dto.setProductName(p.getProductName()));
            MerchantList result = merchantListResultMap.get(x.getMerchantId());
            Optional.ofNullable(result).ifPresent(m -> dto.setMerchantName(m.getMerchantName()));
            return dto;
        }).toList();

        return dtoList;
    }

    /**
     * 分配单列表
     *
     * @param command command
     * @return
     */
    @Override
    public PageResult<OrderUserApplyAllocationMerchantPageDTO> orderUserApplyAllocationPageQueryByDataRole(OrderUserApplyAllocationMerchantPageCommand command) {
        Long accountId = command.getAccountId();
        if (Objects.nonNull(command.getSysUserId())) {
            accountId = merchantExternalService.getAccountIdBySysUserId(command.getSysUserId());
        }
        OrderUserApplyAllocationMerchantPageCondition condition = orderAssembler.formOrderUserApplyAllocationMerchantPageCommand(command);
        condition.setAccountId(accountId);
        long total = orderUserApplyAllocationExtendMapper.countOrderUserApplyAllocationMerchantPageQuery(condition);
        if (total == 0) {
            return PageResult.success(Collections.emptyList(), total);
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyAllocationMerchantPageResult> results = new ArrayList<>();
        //AesEncryptHandler
        if (Objects.nonNull(command.getSysUserId())) {
            //商户用户
            results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationMerchantPageQueryForMerchantUser(condition, command.getSysUserId());
            for (OrderUserApplyAllocationMerchantPageResult dto : results) {
                dto.setUserName(AesUtils.X.decrypt(dto.getUserName(), ""));
                dto.setUserPhone(AesUtils.X.decrypt(dto.getUserPhone(), ""));
            }
        } else {
            //商户管理员
            results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationMerchantPageQuery(condition);
        }

        if (CollUtil.isEmpty(results)) {
            return PageResult.success(Collections.emptyList(), total);
        }
        Set<Long> productIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getProductId).collect(Collectors.toSet());
        Map<Long, ProductSimpleInfo> productInfoMap = productExternalService.listProductInfoByIds(productIds).stream().collect(Collectors.toMap(ProductSimpleInfo::getId, Function.identity()));
        Set<Long> accountIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getCurrentAccountId).collect(Collectors.toSet());
        Map<Long, MerchantAccount> accountListResultMap = merchantExternalService.listAccountInfoByAccountIds(accountIds).stream().collect(Collectors.toMap(MerchantAccount::getAccountId, Function.identity()));
        List<OrderUserApplyAllocationMerchantPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyAllocationMerchantPageDTO dto = orderAssembler.toOrderUserApplyAllocationMerchantPageDTO(x);
            ProductSimpleInfo productResult = productInfoMap.get(x.getProductId());
            Optional.ofNullable(productResult).ifPresent(p -> dto.setProductName(p.getProductName()));
            MerchantAccount accountResult = accountListResultMap.get(x.getCurrentAccountId());
            Optional.ofNullable(accountResult).ifPresent(a -> dto.setCurrentAccountName(a.getAccountName()));
            dto.setEnterpriseWechat(x.getEnterpriseWechat());
            return dto;
        }).toList();

        for (OrderUserApplyAllocationMerchantPageDTO dto : dtoList) {
            List<Team> teams = orderUserApplyAllocationExtendMapper.selectTeamList(dto);
            dto.setUserTeamShips(teams);
        }
        return PageResult.success(dtoList, total);
    }


    /**
     * 未接通列表
     * @param command command
     * @return
     */
    public PageResult<OrderUserApplyAllocationMerchantPageDTO> findAllNoConnectList(OrderUserApplyAllocationMerchantPageCommand command) {
        Long accountId = command.getAccountId();
        if (Objects.nonNull(command.getSysUserId())) {
            accountId = merchantExternalService.getAccountIdBySysUserId(command.getSysUserId());
        }
        OrderUserApplyAllocationMerchantPageCondition condition = orderAssembler.formOrderUserApplyAllocationMerchantPageCommand(command);
        condition.setAccountId(accountId);
        long total = orderUserApplyAllocationExtendMapper.countOrderUserApplyAllocationMerchantPageQuery(condition);
        if (total == 0) {
            return PageResult.success(Collections.emptyList(), total);
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        //List<OrderUserApplyAllocationMerchantPageResult> results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationMerchantPageQuery(condition);
        List<OrderUserApplyAllocationMerchantPageResult> results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationMerchant(condition);
        if (CollUtil.isEmpty(results)) {
            return PageResult.success(Collections.emptyList(), 0);
        }
        Set<Long> productIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getProductId).collect(Collectors.toSet());
        Map<Long, ProductSimpleInfo> productInfoMap = productExternalService.listProductInfoByIds(productIds).stream().collect(Collectors.toMap(ProductSimpleInfo::getId, Function.identity()));
        Set<Long> accountIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getCurrentAccountId).collect(Collectors.toSet());
        Map<Long, MerchantAccount> accountListResultMap = merchantExternalService.listAccountInfoByAccountIds(accountIds).stream().collect(Collectors.toMap(MerchantAccount::getAccountId, Function.identity()));
        List<OrderUserApplyAllocationMerchantPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyAllocationMerchantPageDTO dto = orderAssembler.toOrderUserApplyAllocationMerchantPageDTO(x);
            ProductSimpleInfo productResult = productInfoMap.get(x.getProductId());
            Optional.ofNullable(productResult).ifPresent(p -> dto.setProductName(p.getProductName()));
            MerchantAccount accountResult = accountListResultMap.get(x.getCurrentAccountId());
            Optional.ofNullable(accountResult).ifPresent(a -> dto.setCurrentAccountName(a.getAccountName()));
            return dto;
        }).toList();

        for (OrderUserApplyAllocationMerchantPageDTO dto : dtoList) {
            List<Team> teams = orderUserApplyAllocationExtendMapper.selectTeamList(dto);
            dto.setUserTeamShips(teams);
        }
        return PageResult.success(dtoList, total);
    }


    @Override
    public List<OrderUserApplyAllocationMerchantPageDTO> orderUserApplyAllocationPageQueryByDataRolelist(OrderUserApplyAllocationMerchantPageCommand command) {
        Long accountId = command.getAccountId();
        if (Objects.nonNull(command.getSysUserId())) {
            accountId = merchantExternalService.getAccountIdBySysUserId(command.getSysUserId());
        }
        OrderUserApplyAllocationMerchantPageCondition condition = orderAssembler.formOrderUserApplyAllocationMerchantPageCommand(command);
        condition.setAccountId(accountId);
        long total = orderUserApplyAllocationExtendMapper.countOrderUserApplyAllocationMerchantPageQuery(condition);
        if (total == 0) {
            return Collections.emptyList();
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyAllocationMerchantPageResult> results = orderUserApplyAllocationExtendMapper.orderUserApplyAllocationMerchantPageQuery(condition);
        if (CollUtil.isEmpty(results)) {
            return Collections.emptyList();
        }
        Set<Long> productIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getProductId).collect(Collectors.toSet());
        Map<Long, ProductSimpleInfo> productInfoMap = productExternalService.listProductInfoByIds(productIds).stream().collect(Collectors.toMap(ProductSimpleInfo::getId, Function.identity()));
        Set<Long> accountIds = results.stream().map(OrderUserApplyAllocationMerchantPageResult::getCurrentAccountId).collect(Collectors.toSet());
        Map<Long, MerchantAccount> accountListResultMap = merchantExternalService.listAccountInfoByAccountIds(accountIds).stream().collect(Collectors.toMap(MerchantAccount::getAccountId, Function.identity()));
        List<OrderUserApplyAllocationMerchantPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyAllocationMerchantPageDTO dto = orderAssembler.toOrderUserApplyAllocationMerchantPageDTO(x);
            ProductSimpleInfo productResult = productInfoMap.get(x.getProductId());
            Optional.ofNullable(productResult).ifPresent(p -> dto.setProductName(p.getProductName()));
            MerchantAccount accountResult = accountListResultMap.get(x.getCurrentAccountId());
            Optional.ofNullable(accountResult).ifPresent(a -> dto.setCurrentAccountName(a.getAccountName()));
            return dto;
        }).toList();

        return dtoList;
    }

    @Override
    public OrderUserApplyDetailDTO getOrderUserApplyDetail(String applyOrderNo) {
        OrderUserApplyDetailResult result = orderUserApplyExtendMapper.selectOrderUserApplyDetailByApplyOrderNo(applyOrderNo);
        OrderUserApplyDetailDTO dto = getUserApplyDetail(result);
        OrderUserApplyAllocationDO orderUserApplyAllocationDO = orderUserApplyAllocationExtendMapper.selectByApplyOrderNoAndAllocationTypes(applyOrderNo, null);
        Optional.ofNullable(orderUserApplyAllocationDO).ifPresent(x -> dto.setUserWechat(x.getUserWechat()));
        return dto;
    }

    @Override
    public OrderUserApplyDetailDTO getLastOrderUserApplyDetail(String userCode) {
        OrderUserApplyDetailResult result = orderUserApplyExtendMapper.selectLastOrderUserApplyDetailByUserCode(userCode);
        return getUserApplyDetail(result);
    }

    @Override
    public PageResult<OrderUserApplyPageDTO> orderUserApplyPageQuery(OrderUserApplyPageCommand command) {
        OrderUserApplyPageCondition condition = orderAssembler.formOrderUserApplyPageCommand(command);
        long total = orderUserApplyExtendMapper.countOrderUserApplyPageQuery(condition);
        if (total == 0) {
            return PageResult.success(Collections.emptyList(), total);
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyPageResult> results = orderUserApplyExtendMapper.orderUserApplyPageQuery(condition);
        if (CollUtil.isEmpty(results)) {
            return PageResult.success(Collections.emptyList(), total);
        }
        Set<String> promotionCodes = results.stream().map(OrderUserApplyPageResult::getChannelPromotionCode).collect(Collectors.toSet());
        Map<String, ChannelPromotionInfo> channelPromotionInfoResultMap = channelExternalService.listChannelPromotionInfoByPromotionCodes(promotionCodes).stream().collect(Collectors.toMap(ChannelPromotionInfo::getPromotionCode, Function.identity()));
        List<OrderUserApplyPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyPageDTO dto = orderAssembler.toOrderUserApplyPageDTO(x);
            ChannelPromotionInfo channelPromotionInfoResult = channelPromotionInfoResultMap.get(x.getChannelPromotionCode());
            Optional.ofNullable(channelPromotionInfoResult).ifPresent(c -> {
                dto.setChannelName(c.getChannelName());
                dto.setChannelPromotionName(c.getPromotionName());
            });
            return dto;
        }).toList();
        return PageResult.success(dtoList, total);
    }

    @Override
    public List<OrderUserApplyPageDTO> orderUserApplyPageQueryList(OrderUserApplyPageCommand command) {
        OrderUserApplyPageCondition condition = orderAssembler.formOrderUserApplyPageCommand(command);
        long total = orderUserApplyExtendMapper.countOrderUserApplyPageQuery(condition);
        if (total == 0) {
            return Collections.emptyList();
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
        List<OrderUserApplyPageResult> results = orderUserApplyExtendMapper.orderUserApplyPageQuery(condition);
        if (CollUtil.isEmpty(results)) {
            return Collections.emptyList();
        }
        Set<String> promotionCodes = results.stream().map(OrderUserApplyPageResult::getChannelPromotionCode).collect(Collectors.toSet());
        Map<String, ChannelPromotionInfo> channelPromotionInfoResultMap = channelExternalService.listChannelPromotionInfoByPromotionCodes(promotionCodes).stream().collect(Collectors.toMap(ChannelPromotionInfo::getPromotionCode, Function.identity()));
        List<OrderUserApplyPageDTO> dtoList = results.stream().map(x -> {
            OrderUserApplyPageDTO dto = orderAssembler.toOrderUserApplyPageDTO(x);
            ChannelPromotionInfo channelPromotionInfoResult = channelPromotionInfoResultMap.get(x.getChannelPromotionCode());
            Optional.ofNullable(channelPromotionInfoResult).ifPresent(c -> {
                dto.setChannelName(c.getChannelName());
                dto.setChannelPromotionName(c.getPromotionName());
            });
            return dto;
        }).toList();

        return dtoList;
    }

    /**
     * 获取用户申请订单详情响应对象
     *
     * @param result result
     * @return OrderUserApplyDetailDTO
     */
    private OrderUserApplyDetailDTO getUserApplyDetail(OrderUserApplyDetailResult result) {
        if (Objects.isNull(result)) {
            return null;
        }
        OrderUserApplyDetailDTO dto = orderAssembler.toOrderUserApplyDetailDTO(result);
        if (Objects.isNull(result.getAge()) && StringUtils.isNotBlank(result.getUserIdentityNo())) {
            dto.setAge(IdCardNumberUtils.X.getAgeForIdCard(result.getUserIdentityNo()));
            dto.setGender(IdCardNumberUtils.X.getSexFromIdCard(result.getUserIdentityNo()));
        }
        dto.setAccumulationFund("有");
        if (AccumulationFundLevelEnum.NO_ACCUMULATION_FUND.getValue().equals(result.getAccumulationFundLevel())) {
            dto.setAccumulationFund("无");
        }
        dto.setSocialSecurity("有");
        if (SocialSecurityLevelEnum.NO_SOCIAL_SECURITY.getValue().equals(result.getSocialSecurityLevel())) {
            dto.setSocialSecurity("无");
        }
        return dto;
    }


    /**
     * 分页查询二次uv统计表
     *
     * @param command
     * @return
     */
    @Override
    public PageResult<ChannelPromotionTwoUvStatisticsDto> twoUvOrderStatistics(OrderUserApplyAllocationPageCommand command) {
        OrderUserApplyAllocationPageCondition condition = orderAssembler.formOrderUserApplyAllocationPageCommand(command);
        long total = uvStatisticsMapper.countOrderUserApplyAllocationPageQuery(condition);
        if (total == 0) {
            return PageResult.success(Collections.emptyList(), total);
        }
        condition.setOffset(PageQueryUtils.X.getOffset(command.getPageNum(), command.getPageSize()));
           List<ChannelPromotionTwoUvStatisticsVo> results = uvStatisticsMapper.twoUvOrderStatistics(condition);
        if (CollUtil.isEmpty(results)) {
            return PageResult.success(Collections.emptyList(), total);
        }
        Map<Integer, String> map = Map.of(1, "<600", 2, "600-650", 3, "651-700", 4, ">700");
        List<ChannelPromotionTwoUvStatisticsDto> list = results.stream().map(x -> format(x, map)).toList();
        return PageResult.success(list,total);
    }


    /**
     * 二次uv统计查询参数转化
     */
    private ChannelPromotionTwoUvStatisticsDto format(ChannelPromotionTwoUvStatisticsVo base,Map<Integer, String> map){
        ChannelPromotionTwoUvStatisticsDto dto = new ChannelPromotionTwoUvStatisticsDto();
        dto.setUserName(base.getUserName());
        dto.setUserPhone(base.getUserPhone());
        dto.setApplyOrderNo(base.getApplyOrderNo());
        dto.setProductName(base.getProductName());
        dto.setAge(base.getAge());
        dto.setUvJoin(base.getUvJoin());
        dto.setApplyCity(base.getApplyCity());
        dto.setSesameSeedQuota(map.get(base.getSesameSeedQuota()));
        dto.setChannelPromotion(base.getChannelPromotion());
        if (Objects.isNull(base.getBeOver())){
            dto.setBeOver("");
        } else if (1 == base.getBeOver()){
            dto.setBeOver("否");
        } else {
            dto.setBeOver("是");
        }
        dto.setCreatTime(base.getCreatTime());
        return dto;
    }
}
